package Demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-22
 * Time: 19:57
 */
/* 定义标识接口——信息        */
interface Info{

}

/* 定义第1个表示信息的类——联系方式，此类实现Info接口       */
class Contact implements Info{
    private String address;
    private String telephone;
    private String zipcode;

    public Contact(String address, String telphone, String zipcode) {
        this.address = address;
        this.telephone = telphone;
        this.zipcode = zipcode;
    }
    public String toString() {
        return "联系方式："+"\n"+"地址：" + address + "，电话：" + telephone + "，邮政编码：" + zipcode;
    }
}

/* 定义第2个表示信息的类——个人基本信息，此类实现Info接口       */
class Introduction implements Info{
    private String nativePlace;
    private String sex;
    private int age;

    public Introduction(String nativePlace, String sex, int age) {
        this.nativePlace = nativePlace;
        this.sex = sex;
        this.age = age;
    }
    public String toString() {
        return "基本信息："+"\n"+"籍贯："+nativePlace+"，性别："+sex+"，年龄："+age;
    }
}

/* 定义Person类，类中info属性的类型使用泛型        */
class Person<T extends Info>{
        private String name;
        private  T info;

    public Person(String name, T info) {
        this.name = name;
        this.info = info;
    }
    @Override
    public String toString() {
        return this.name+info.toString();
    }
}
/* 请在这里填写答案 */

public class Main {
    public static void main(String[] args) {
        Contact c=new Contact("北京市","0103456789","100088");
        Person<Contact>per1=new Person<Contact>("张三",c);   //实例化Person对象,同时指定Contact类型
        System.out.println(per1);
        Introduction in=new Introduction("福建","男",30);
        Person<Introduction> per2=new Person<Introduction>("李四",in);//实例化Person对象,同时指定Introductiont类型
        System.out.println(per2);
    }
}